package com.jnks.constant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@AllArgsConstructor
public enum DeviceCategTypeEnum {
    DETECT_DEVICE(1, "1", "侦测设备"),

    STRIKE_DEVICE(2, "2", "反制设备");

    @Getter
    @Setter
    private Integer intCode;//设备大类
    @Getter
    @Setter
    private String code;
    @Getter
    @Setter
    private String message;

    public static DeviceCategTypeEnum getByCode(String code) {
        if (null == code) {
            return null;
        }

        for (DeviceCategTypeEnum deviceTypeEnum : DeviceCategTypeEnum.values()) {
            if (deviceTypeEnum.getCode().equals(code)) {
                return deviceTypeEnum;
            }
        }

        return null;
    }

    /**
     * 转化枚举为Map,key为code, value为message
     *
     * @return
     */
    public static Map<String, Integer> convert2Map() {
        Map<String, Integer> map = new HashMap<String, Integer>();
        for (DeviceCategTypeEnum deviceTypeEnum : DeviceCategTypeEnum.values()) {
            map.put(deviceTypeEnum.getCode(), deviceTypeEnum.getIntCode());
        }
        return map;
    }
}
